<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="ko">
<head>
	<%@ include file="/include/header.jsp" %>
	<link rel="stylesheet" href="<%=cp %>/css/board.css">
	<%@ include file="/include/commonRes.jsp" %>
	<script type="text/javascript">
		$(function(){
			
			$("#bo_cate_ul li a").click(function(){
				var boardCodeId=$(this).attr("id");
				
				var clickval="";
				if(boardCodeId=="board_all"){
					clickval="";
				}else if(boardCodeId=="board_notic"){
					clickval="1";
				}else if(boardCodeId=="board_hosp"){
					clickval="2";
				}else if(boardCodeId=="board_health"){
					clickval="3";
				}else if(boardCodeId=="board_idea"){
					clickval="4";
				}
				
				
				
				$("#tabclickForm input[name='boardCode']").val(clickval);
				$("#tabclickForm").submit();
				return false;
			});
			
			
			
			$("input[name='chk_wr_id']").click(function(){
				var allcnt=$("input[name='chk_wr_id']").size();
				var chkcnt=$("input[name='chk_wr_id']:checked").size();
				
				var chkall=$("#chkall");
				
				if(chkcnt==allcnt){
					chkall.attr("checked","checked");
				} else{
					chkall.removeAttr("checked");
				}
			});
			
			$("#wr_delete").click(function(){
				
				if(!confirm("선택한 글들을 삭제 하시겠습니까?")) {
					return false;
				}
				
				var chk_contents=$("input[name='chk_wr_id']:checked");
				var chkArr=new Array();
				
				if(chk_contents.size()<=0){
					alert("삭제할 글을 선택하여주세요.");
					return false;
				}			
				for(var seq=0;seq<chk_contents.size();seq++){
					var chk_content=chk_contents[seq].value

					chkArr.push(chk_content);
				}
				
				var paramData={"boardSeq":chkArr.toString()};
				
				var success=function(data){
					if(data=="0000"){
						alert("삭제 처리가 정상적으로 적용 되었습니다.");
					} 
					location.reload();
				}
				var error=function(xhr,error,response){
					alert("시스템 오류입니다. 다시 시도해주세요.");
				}
				var dataType="html";
				var type="POST";
				var url="<%=cp%>/bbs/notice_deleteList.do";
				sendAjax(type,dataType,url,paramData,success,error);
				
				
				return false;
			});
			
			$("#chkall").click(function(){
				var isChk=$(this).is(":checked");
				var chk_wr_id=$("input[name='chk_wr_id']");
				
				if(isChk) {
					chk_wr_id.attr("checked","checked");
				} else {
					chk_wr_id.removeAttr("checked");
				}
			});
			$("#btn_write").click(function(){
				$("#regFrm").submit();
				return false;
			});
			
		});
		function search(){
			$("#listFrm input[name='page']").val(1);
			return true;
		}
		function view(board_seq){
			$("#viewForm input[name='boardSeq']").val(board_seq);
			$("#viewForm").submit();
		}
		
	</script>
</head>
<body>
<div id="hd_login_msg">최고관리자 최고관리자님 로그인 중 <a href="<%=cp%>/logout.do">로그아웃</a></div>

<%@include file="/include/mainMenuHeader.jsp" %>
<div id="wrapper">
	<h2 id="container_title">공지사항<span class="sound_only"> 목록</span></h2>
	
	<div id="bo_list">
		<nav id="bo_cate">
	    	<h2>공지 사항 카테고리</h2>
	    	<ul id="bo_cate_ul">
           		<li>
					<a href="#" id="board_all" <c:if test="${empty boardCode }">class="blackBold"</c:if>>전체</a>
				</li>
				<li>
					<a href="#" id="board_notic" <c:if test="${boardCode=='1' }">class="blackBold"</c:if>>공고</a>
				</li>
				<li>
					<a href="#" id="board_hosp" <c:if test="${boardCode=='2' }">class="blackBold"</c:if>>병원관련</a>
				</li>
				<li>
					<a href="#" id="board_health" <c:if test="${boardCode=='3' }">class="blackBold"</c:if>>진료관련</a>
				</li>
				<li>
					<a href="#" id="board_idea" <c:if test="${boardCode=='4' }">class="blackBold"</c:if>>아이디어</a>
				</li>        
			</ul>
	    </nav>
	    
	    <div class="bo_fx">
	    	
	    	<div id="bo_list_total">
	            <span>Total ${totalcnt }건</span>${page }페이지
	        </div>
			<div class="right_align_area">
	            <c:if test="${sessionScope.ss_mb.mb_auth_code==7 || sessionScope.ss_mb.mb_auth_code==8}">
		            <ul class="btn_bo_user">
				        <li>
				        	<input type="button" name="btn_submit" value="선택삭제" id="wr_delete" class="btn_red">
				        	<!-- <button name="btn_submit" id="wr_delete" class="btn_red">선택삭제</button> -->
				       	</li>            
				       	<li>
				       		<a href="#" class="btn_b02" id="btn_write">글쓰기</a>
				       	</li>        
			        </ul>
		        </c:if>
	        </div>
	        <!-- list -->
		    <div class="tbl_head01 tbl_wrap">
		        <div class="notice_li_table">
					<ul class="subject th">
						<li class="col chk_area"><input type="checkbox" id="chkall"></li>
						<li class="num_area">번호</li>
						<li class="title_area">제목</li>
						<li class="date_area">작성일</li>
					</ul>
					<c:if test="${empty list }">
						<ul class="content">
							<li class="emptyList">목록이 없습니다.</li>
						</ul>
					</c:if>
					<c:if test="${not empty list }">
						<c:forEach var="item" items="${list}">
							<ul class="content">
								<li class="col font11 chk_area"><input type="checkbox" name="chk_wr_id" value="${item.boardSeq }" /></li>
								<li class="font11 num_area">${item.row }<c:if test="${empty item.row}">&nbsp;</c:if></li>
								<c:if test="${empty boardCode }">
									<li class="font11 title_area">
										<a href="#" onclick="view('${item.boardSeq}')"> 
											<span class="fontBold">[${item.boardName}]</span>&nbsp;${item.boardTitle}<c:if test="${empty item.boardTitle}">&nbsp;</c:if>
										</a>
									</li>
								</c:if>
								<c:if test="${not empty boardCode }">
									<li class="font11 title_area">
										<a href="#" onclick="view('${item.boardSeq}')"> 
											${item.boardTitle}<c:if test="${empty item.boardTitle}">&nbsp;</c:if>
										</a>
									</li>
								</c:if>
								<li class="font11 date_area">${item.regDate}<c:if test="${empty item.regDate}">&nbsp;</c:if></li>
 							</ul>
						</c:forEach>
					</c:if>
				</div>
		    </div>
	    </div>

		<!-- 검색조건 -->
		<fieldset id="bo_sch">
		    <legend>게시물 검색</legend>
			
		    <form id="regFrm" name="regFrm" method="get" action="<%=cp%>/bbs/notice_edit.do">
	
		    </form>
		    <form method="post" id="viewForm" action="<%=cp%>/bbs/notice_view.do">
				<input type="hidden"   name="boardSeq" value="" />
			</form>
			<form method="get" id="editForm" action="<%=cp%>/bbs/notice_edit.do">
				<input type="hidden"   name="board_seq" value="" />
			</form>
			
			<form method="post" id="tabclickForm">
				<input type="hidden"   name="boardCode" value="" />
			</form>
		
			<form id="pageFrm" name="pageFrm" method="post">
				<input type="hidden"   name="boardCode" value="${boardCode }" />
			    <input type="hidden" name="page" value="${page }" >
			    <input type="hidden" name="typeSelect" value="${typeSelect }">
			    <input  type="hidden" name="input"   value="${input }">
		    </form>
		    
		    <form id="pageFrm" name="pageFrm" method="post">
				<input type="hidden"   name="boardCode" value="${boardCode }" />
			    <input type="hidden" name="page" value="${page }" >
			    <input type="hidden" name="typeSelect" value="${typeSelect }">
			    <input  type="hidden" name="input"   value="${input }">
		    </form>
		    
		
		    <form id="listFrm" name="listFrm" method="post" onsubmit="search()">
			    <input type="hidden"   name="boardCode" value="${boardCode }" />
			    <input type="hidden" name="page" value="${page }">
			    <label for="sfl" class="sound_only">검색대상</label>
			    
			    
			    <select id="typeSelect" name="typeSelect">
			        <option value="title" <c:if test="${typeSelect=='title' }">selected</c:if>>제목</option>
			        <option value="contents" <c:if test="${typeSelect=='contents' }">selected</c:if>>내용</option>
			    </select>
			    <input name="input"  placeholder="검색어(필수)" class="frm_input size100"  id="input"  value="${input }">
			    <input type="submit" value="검색" class="btn_submit" />
		    	
		    </form>
		    
		</fieldset>
		
	</div>
	<%@ include file="/include/pageInc.jsp"%>
</div>
<%@ include file="/include/footer.jsp" %>

</body>
</html>